<?php

namespace App\Models;

use App\Utils\NumberToChinese;
use Illuminate\Database\Eloquent\Model;

class FinanceExpensesModel extends Model
{
    protected $table = 'finance_expenses';

    public function getInvoiceProofAttribute($value)
    {
        return json_decode($value, true);
    }

    public function setInvoiceProofAttribute($value): void
    {
        $this->attributes['invoice_proof'] = json_encode($value);
    }

    protected $appends = ['amount_display'];

    public function getAmountDisplayAttribute()
    {
        return NumberToChinese::convert($this->amount);
    }
}
